﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Finance.IBll;
using Finance.Bll;
using Finance.Utility;

namespace Finance.UI.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        IUserBll userBll = new UserBll();
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login(string userName, string password, bool rememberMe=false)
        {
            if (userBll.ValidateUser(userName,Encrypt.Md5( password)))
            {
                FormsAuthentication.SetAuthCookie(userName, rememberMe);

                return RedirectToRoute("FinanceManager_default", new { controller = "Dashboard", action = "Index" });
            }
            return View("Index");
        }

        public ActionResult Logout()
        {
            FormsAuthentication.SignOut();
            return RedirectToAction("Login");
        }
    }
}
